package io.xiyou.account2.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.xiyou.account2.dao.model.AccountInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

@Repository
public interface AccountInfoMapper extends BaseMapper<AccountInfo> {

    @Update("update account_info set account_balance=account_balance - #{money} where account_balance>=#{money} and account_id=#{accountId} ")
    int subtractAccountBalance(@Param("accountId") Long accountId, @Param("money") BigDecimal money);

    @Update("update account_info set account_balance=account_balance + #{money} where account_id=#{accountId} ")
    int addAccountBalance(@Param("accountId") Long accountId, @Param("money") BigDecimal money);

}